$(function () {
    let navId = localStorage.getItem("navId");
    findNavById(navId)
});

//通过id查找
function findNavById(id) {
    let result = myAjax('/back/nav/findByNavId','get',{id:id,token:$.cookie("token")});
    setNavData(result.navModel);
}

function setNavData(data) {
    $("#navId").val(data.id);
    $("#name").val(data.name);
    $("#href").val(data.href);
}

function cancelEdit() {
    $("#right").load('/back/nav/navManage.html')
}

function navEdit() {
    let data = {
        id:$("#navId").val(),
        name: $("#name").val(),
        href: $("#href").val(),
        token:$.cookie("token")
    };
    let result = myAjax('/back/nav/navEdit','post',data);
    if (result.count===1){
        alert("修改成功！")
        $("#right").load('/back/nav/navManage.html')
    }else{
        alert("修改失败")
    }
}
